Skip to content

Conversation

@thewhaleking
Copy link
Collaborator

Because of the way the CachedFetcher worked, if an exception was raised on a cached method, it would eternally keep a copy of the exception, and then when the event loop closed, would spit out a traceback for a never-retrieved-exception, like so:

Traceback Future exception was never retrieved future: Traceback (most recent call last): File "/Users/benjaminhimes/Git/btcli/bittensor_cli/src/commands/proxy.py", line 625, in execute_announced runtime = await subtensor.substrate.init_runtime(block_id=created_block) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 1433, in init_runtime runtime_version = await self.get_block_runtime_version_for(block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/utils/cache.py", line 332, in __call__ result = await self._method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2390, in get_block_runtime_version_for return await self._get_block_runtime_version_for(block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2394, in _get_block_runtime_version_for runtime_info = await self.get_block_runtime_info(parent_block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/utils/cache.py", line 332, in __call__ result = await self._method(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2377, in get_block_runtime_info return await self._get_block_runtime_info(block_hash) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2382, in _get_block_runtime_info response = await self.rpc_request("state_getRuntimeVersion", [block_hash]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/benjaminhimes/Git/async-substrate-interface/async_substrate_interface/async_substrate.py", line 2728, in rpc_request raise StateDiscardedError(bh) async_substrate_interface.errors.StateDiscardedError: State discarded for 0x32cf28ae40a6f5f89fa224fdffd5454314105eef3c7cf234bd4ea3b3ab92dbf2. This indicates the block is too old, and you should instead make this request using an archive node.

This fixes that issue by not caching the exceptions.

@github-actions github-actions bot added run-bittensor-sdk-tests Runs Bittensor SDK tests. run-bittensor-cli-tests Runs BTCLI tests. labels Dec 19, 2025
@ibraheem-abe ibraheem-abe changed the base branch from master to staging December 19, 2025 07:58
@thewhaleking
Copy link
Collaborator Author

BTCLI test fixes: opentensor/btcli#775

@thewhaleking thewhaleking merged commit 1972840 into staging Dec 20, 2025
139 of 143 checks passed
@thewhaleking thewhaleking deleted the fix/thewhaleking/dont-cache-exceptions branch December 20, 2025 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-bittensor-cli-tests Runs BTCLI tests. run-bittensor-sdk-tests Runs Bittensor SDK tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants